package com.bluesky.mq.sender;

import com.bluesky.mq.po.MsgPO;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

/**
 * 消息发送器
 */
public interface IMsgSender {

    /**
     * 批量发送消息
     * @param msgList
     */
    void send(List<Object> msgList);

    default void send(Object msg){
        Objects.nonNull(msg);
        this.send(Arrays.asList(msg));
    }

    /**
     * 批量投递延迟消息
     * @param delaySeconds  延迟时间
     * @param delayTimeUnit 延迟时间单位
     * @param msgList       消息
     */
    void send(long delaySeconds, TimeUnit delayTimeUnit, List<Object> msgList);


    default void send(long delaySeconds, TimeUnit delayTimeUnit, Object msg){
        // Objects.nonNull(msg);
        this.send(delaySeconds, delayTimeUnit, Arrays.asList(msg));
    }


    /**
     * 投递重试
     * @param msgPO
     */
    void sendRetry(MsgPO msgPO);


}
